package main

import (
	"net/http"
	"bytes"
	"fmt"
	"io/ioutil"
)

func main()  {
	url := "http://127.0.0.1:8080/auth/test?aa=bb"

	code := "lskdfjlksdjflksdjfklsjdfkl"
	//json序列化
	post := "{\"client_id\": \"e08abc91-be29-4ba1-bc14-343d755bfc8e\", \"code\": "+ code +",\"client_secret\": \"626994c24d56386430a9dc240f2a8c511a33ec44bbd05ad9a0b3d7b122b48742\"}"

	// 发送http post json数据
	req, err := http.NewRequest("POST", url, bytes.NewBuffer([]byte(post)))

	if err != nil {
		fmt.Println("http newRequest error", err)
		return
	}

	//req.Header.Set("Content-Type", "application/json")
	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	fmt.Println("response Status:", resp.Status)
	fmt.Println("response Headers:", resp.Header)
	body, _ := ioutil.ReadAll(resp.Body)
	fmt.Println("response Body:", string(body))
}